<template>
  <div>
    <van-nav-bar
      title="兑换详情"
      left-arrow
      @click-left="onClickLeft"
      fixed
    ></van-nav-bar>
    <div class="top" v-for="item in detail" :key="Math.random(item.id)">
      <van-image :src="item.img"></van-image>
      <div class="info">
        <h2>{{ item.kname }}</h2>
        <div class="num">
          <p v-if="item.cash"><b>{{ item.points }}</b>&nbsp;积分&nbsp;+&nbsp;<b>{{ item.cash }}</b>&nbsp;元</p>
          <p v-else><b>{{ item.points }}</b>&nbsp;积分</p>
          <p>剩余&nbsp;<b>{{ item.rest }}</b>&nbsp;件</p>
        </div>
      </div>
    </div>
    <div class="middle" v-for="item in detail" :key="Math.random(item.id)">
      <p v-html="item.notice"></p>
    </div>
    <div class="bottom" v-for="item in detail" :key="Math.random(item.id)">
      <p v-html="item.attention"></p>
    </div>
    <div class="fixed">
      <button class="btn">立即兑换</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      detail: [], //保存详情数据
    };
  },
  mounted() {
    let id = this.$route.params.id;
    console.log(id);
    this.axios.get(`/integral/${id}`).then((res) => {
      this.detail = res.data.data;
      console.log("兑换详情：", this.detail);
    });
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .van-icon {
  color: black;
}
.top {
  margin: 46px 0 5vw;
  background-color: #fff;
}
.top .info {
  text-align: left;
  padding: 4vw 6vw;
}
.top .info h2 {
  margin-bottom: 3vw;
  font-size: 4vw;
}
.top .info p {
  font-size: 3vw;
}
.top .info .num {
  display: flex;
  justify-content: space-between;
}
.top .info .num b {
  color: #a7d500;
  font-size: 4vw;
}
.middle {
  margin: 5vw 0;
  padding: 4vw 6vw;
  text-align: left;
  background-color: #fff;
}
.middle p {
  margin: 1vw 0; 
  font-size: 4vw;
  line-height: 6vw;
}
.bottom {
  margin-bottom: 21vw;
  padding: 4vw 6vw;
  text-align: left;
  background-color: #fff;
}
.bottom p {
  margin: 1vw 0;
  font-size: 4vw;
  line-height: 6vw;
}
.fixed {
  width: 100vw;
  height: 20vw;
  background-color: #fff;
  box-shadow: 0 0 3px 2px #fafafd;
  position: fixed;
  left: 0;
  bottom: 0;
}
.fixed .btn {
  width: 90vw;
  height: 14vw;
  margin: 3vw auto;
  border: none;
  border-radius: 10vw;
  color: #fff;
  background-color: #a7d500;
  font-size: 5vw;
  opacity: 0.6;
}
</style>
